import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import {resolve}  from 'path'

// https://vite.dev/config/
export default defineConfig({
  base: '/rcam/',
  plugins: [
    vue(),
    vueJsx(),
    vueDevTools(),
    Components({
      resolvers: [VantResolver()]
    })
  ],
  build: {
    outDir: 'dist', // 默认输出目录
    assetsDir: 'assets' // 静态资源目录
  },
  server: {
    host: '0.0.0.0',
    port: 8089,
    proxy: {
      // 匹配以 /api 开头的请求，将其代理到目标服务器
      '/szgkapi': {
        target: 'http://120.221.72.59:8088',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/szgkapi/, '')
      }
    }
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    },
  },

})
